[Panel]
Title=%rsObserverTool
HidenTimer=0
NumToolbar1=3
toolbar1_0=48;TelescopeConnect
toolbar1_1=98;Obslist
toolbar1_2=78;Position
NumToolbar2=0
NumComponent=50
component_0="Group_7;Target;2"
component_1="	Edit_1"
component_2="	Edit_2"
component_3="Group_1;Telescope;2"
component_4="	Button_1;Goto"
component_5="	Button_2;Sync"
component_6="	Edit_3"
component_7="	Edit_4"
component_8="	Button_3;Cancel Goto"
component_9="	Button_4;Follow"
component_10="	Button_15;Connect"
component_11="Group_4;Hand pad;5"
component_12="	Spacer_5"
component_13="	Spacer_1"
component_14="	Button_9;^"
component_15="	Spacer_4"
component_16="	Spacer_6"
component_17="	Spacer_2"
component_18="	Button_10;<"
component_19="	Button_11;Stop"
component_20="	Button_12;>"
component_21="	Spacer_7"
component_22="	Spacer_8"
component_23="	Spacer_3"
component_24="	Button_13;v"
component_25="	Spacer_9"
component_26="	Spacer_10"
component_27="Group_5;;1"
component_28="	CheckList_1;50"
component_29="	Combo_1;"
component_30="Group_6;;2"
component_31="	Edit_5"
component_32="	Button_14;Search"
component_33="Group_3;Observing list;2"
component_34="	Button_7;First object"
component_35="	Button_8;Last object"
component_36="	Button_5;< Prev object"
component_37="	Button_6;Next object >"
component_38="Group_2;Information;1"
component_39="	Memo_1;150"
component_40="	Event_0;0;Initialisation"
component_41="	Event_1;1;Activation;"
component_42="	Event_2;2;Timer;300"
component_43="	Event_3;3;Telescope move"
component_44="	Event_4;4;Chart refresh;"
component_45="	Event_5;5;Object identification click"
component_46="	Event_6;6;Distance measurement"
component_47="	Event_7;7;Telescope connected;"
component_48="	Event_8;8;Telescope disconnected;"
component_49="	Event_9;9;Translation;"

[button_1]
s="// Slew telescope"
"  var ra,de: double;"
"      a,b,r: string;"
"      c: Tstringlist;"
"  begin"
"  memo_1.clear;"
"  if MenuTelescopeConnect.checked then begin"
"    if not StrToAR(Edit_1.text,ra) then begin memo_1.lines.add(rserror+' RA!');exit;end;"
"    if not StrToDE(Edit_2.text,de) then begin memo_1.lines.add(rserror+' DE!');exit;end;"
"    a:=floattostr(ra);"
"    b:=floattostr(de);"
"    GetSL('STRL1',c);"
"    c.clear;"
"    c.add('SLEW');"
"    c.add(a);"
"    c.add(b);"
"    r:=cmd('',c);"
"    c.clear;"
"    memo_1.lines.add(r);"
"  end"
"  else memo_1.lines.add(rsTelescopeNot);"
"  end."


[button_2]
s="// Sync telescope"
"  var ra,de: double;"
"      a,b,r: string;"
"      c: Tstringlist;"
"  begin"
"  memo_1.clear;"
"  if MenuTelescopeConnect.checked then begin"
"   if MsgBox(Format(rsPleaseConfir, [Edit_1.text+' '+Edit_2.text])) then begin"
"    if not StrToAR(Edit_1.text,ra) then begin memo_1.lines.add(rserror+' RA!');exit;end;"
"    if not StrToDE(Edit_2.text,de) then begin memo_1.lines.add(rserror+' DE!');exit;end;"
"    a:=floattostr(ra);"
"    b:=floattostr(de);"
"    GetSL('STRL1',c);"
"    c.clear;"
"    c.add('SYNC');"
"    c.add(a);"
"    c.add(b);"
"    r:=cmd('',c);"
"    c.clear;"
"    memo_1.lines.add(r);"
"   end;"
"  end"
"  else memo_1.lines.add(rsTelescopeNot);"
"  end."


[button_3]
s="// Cancel Slew"
"  var c: Tstringlist;"
"      r: string;"
"  begin"
"  memo_1.clear;"
"  if MenuTelescopeConnect.checked then begin"
"    GetSL('STRL1',c);"
"    c.clear;"
"    c.add('ABORTSLEW');"
"    r:=cmd('',c);"
"    c.clear;"
"    memo_1.lines.add(r);"
"  end"
"  else memo_1.lines.add(rsTelescopeNot);"
"  end."


[button_4]
s="// Track telescope"
"  var c: Tstringlist;"
"      r,onoff: string;"
"  begin"
"  memo_1.clear;"
"  if MenuTrackTelescope.checked then"
"     onoff:='OFF'"
"  else"
"     onoff:='ON';"
"  if MenuTelescopeConnect.checked then begin"
"    GetSL('STRL1',c);"
"    c.clear;"
"    c.add('TRACKTELESCOPE');"
"    c.add(onoff);"
"    r:=cmd('',c);"
"    c.clear;"
"    memo_1.lines.add(r);"
"  end"
"  else memo_1.lines.add(rsTelescopeNot);"
"  end."


[button_15]
s="// Connect the configured telescope"
"var c: Tstringlist;"
"    r: string;"
"begin"
"  memo_1.clear;"
"  if not MenuTelescopeConnect.checked then begin"
"    GetSL('STRL1',c);"
"    c.clear;"
"    c.add('CONNECTTELESCOPE');"
"    r:=cmd('',c);"
"    c.clear;"
"    memo_1.lines.add(r);"
"  end"
"  else memo_1.lines.add(rsConnected);"
"  end."
"end."


[button_9]
s="// Move scope up"
"var c: Tstringlist;"
"    r: string;"
"begin"
" memo_1.clear;"
" if MenuTelescopeConnect.checked then begin"
"   GetSL('STRL1',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('1');"
"   if CheckList_1.Checked[0] then"
"      c.add('-'+Combo_1.text)"
"   else"
"      c.add(Combo_1.text);"
"   r:=cmd('',c);"
"   c.clear;"
"   memo_1.lines.add(r);"
" end"
" else memo_1.lines.add(rsTelescopeNot);"
"end."


[button_10]
s="// Move scope left"
"var c: Tstringlist;"
"    r: string;"
"begin"
" memo_1.clear;"
" if MenuTelescopeConnect.checked then begin"
"   GetSL('STRL1',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('0');"
"   if CheckList_1.Checked[1] then"
"      c.add('-'+Combo_1.text)"
"   else"
"      c.add(Combo_1.text);"
"   r:=cmd('',c);"
"   c.clear;"
"   memo_1.lines.add(r);"
" end"
" else memo_1.lines.add(rsTelescopeNot);"
"end."


[button_11]
s="// Stop moving"
"var c: Tstringlist;"
"    r: string;"
"begin"
" memo_1.clear;"
" if MenuTelescopeConnect.checked then begin"
"   GetSL('STRL1',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('0');"
"   c.add('0');"
"   r:=cmd('',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('1');"
"   c.add('0');"
"   r:=cmd('',c);"
"   memo_1.lines.add(r);"
" end"
" else memo_1.lines.add(rsTelescopeNot);"
"end."


[button_12]
s="// Move scope right"
"var c: Tstringlist;"
"    r: string;"
"begin"
" memo_1.clear;"
" if MenuTelescopeConnect.checked then begin"
"   GetSL('STRL1',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('0');"
"   if CheckList_1.Checked[1] then"
"      c.add(Combo_1.text)"
"   else"
"      c.add('-'+Combo_1.text);"
"   r:=cmd('',c);"
"   c.clear;"
"   memo_1.lines.add(r);"
" end"
" else memo_1.lines.add(rsTelescopeNot);"
"end."


[button_13]
s="// Move scope down"
"var c: Tstringlist;"
"    r: string;"
"begin"
" memo_1.clear;"
" if MenuTelescopeConnect.checked then begin"
"   GetSL('STRL1',c);"
"   c.clear;"
"   c.add('SCOPEMOVEAXIS');"
"   c.add('1');"
"   if CheckList_1.Checked[0] then"
"      c.add(Combo_1.text)"
"   else"
"      c.add('-'+Combo_1.text);"
"   r:=cmd('',c);"
"   c.clear;"
"   memo_1.lines.add(r);"
"end"
" else memo_1.lines.add(rsTelescopeNot);"
"end."


[button_14]
s="// Search for an object name"
"var cm:TstringList;"
"    str:string;"
"    p: integer;"
"begin"
"    GetSL('STRL1',cm);"
"    cm.clear;"
"    cm.add('SEARCH');"
"    cm.add(Edit_5.Text);"
"    str:=cmd('',cm);"
"    p:=pos('OK!',str);"
"    if p=0 then memo_1.lines.add(rserror+' '+Edit_5.Text+' '+str);"
"    cm.clear;"
"end."


[button_7]
s="// First in observing list"
"var c: TStringlist;"
"    r:  String;"
"begin"
"  GetSL('STRL1',c);"
"  c.clear;"
"  c.add('OBSLISTFIRST');"
"  r:=cmd('',c);"
"  c.clear;"
"end."


[button_8]
s="// Last in observing list"
"var c: TStringlist;"
"    r:  String;"
"begin"
"  GetSL('STRL1',c);"
"  c.clear;"
"  c.add('OBSLISTLAST');"
"  r:=cmd('',c);"
"  c.clear;"
"end."


[button_5]
s="// Previous in observing list"
"var c: TStringlist;"
"    r:  String;"
"begin"
"  GetSL('STRL1',c);"
"  c.clear;"
"  c.add('OBSLISTPREV');"
"  r:=cmd('',c);"
"  c.clear;"
"end."


[button_6]
s="// Next in observing list"
"var c: TStringlist;"
"    r:  String;"
"begin"
"  GetSL('STRL1',c);"
"  c.clear;"
"  c.add('OBSLISTNEXT');"
"  r:=cmd('',c);"
"  c.clear;"
"end."


[event_0]
s="// Initialization"
"begin"
"  // change attribute"
"  edit_3.readonly:=true;"
"  edit_3.enabled:=false;"
"  edit_4.readonly:=true;"
"  edit_4.enabled:=false;"
"  Combo_1.style:=csDropDownList;"
"  memo_1.clear;"
"  CheckList_1.Clear;"
"  CheckList_1.Items.Add(rsSwapButton+' N/S');"
"  CheckList_1.Items.Add(rsSwapButton+' E/W');"
"end."


[event_1]
s="// Script activation event"
"var str,buf,longstr: string;"
"    p: integer;"
"begin"
"// Info about current object"
" getS('SelectionText',str)"
" getS('DescriptionText',longstr)"
" if trim(str)<>'' then begin"
"   // coordinates from selected object"
"   // Get RA"
"   p:=pos(chr(9),str);"
"   buf:=copy(str,1,p-1);"
"   edit_1.text:=buf;"
"   delete(str,1,p);"
"   // Get Dec"
"   p:=pos(chr(9),str);"
"   buf:=copy(str,1,p-1);"
"   edit_2.text:=buf;"
" end else begin"
"   // coordinates from chart center"
"   getS('RefreshText',str)"
"   p:=pos('C:',str);"
"   if p>0 then begin"
"     delete(str,1,p+1);"
"     str:=trim(str);"
"     // RA"
"     p:=pos(' ',str);"
"     buf:=trim(copy(str,1,p));"
"     edit_1.text:=buf;"
"     delete(str,1,p);"
"     // Dec"
"     p:=pos(' ',str);"
"     buf:=trim(copy(str,1,p));"
"     edit_2.text:=buf;"
"   end;"
" end;"
" if trim(longstr)<>'' then begin"
"   // show other information line by line"
"   memo_1.clear;"
"   memo_1.text:=longstr;"
"   memo_1.selstart:=0;"
" end;"
"end."


[event_2]
s="// Timer event"
"var  t,h: Double;"
"     a,r: string;"
"     c: TStringlist;"
"begin"
"  // display time"
"  getd('TimeNow',t);"
"  h:=24*(t-trunc(t));"
"  a:=artostr(h);"
"  memo_1.lines.add('Time is '+a);"
"  // actualize the observing list filter"
"  GetSL('STRL1',c);"
"  c.clear;"
"  c.add('OBSLISTLIMIT');"
"  c.add('ON');"
"  r:=cmd('',c);"
"  c.clear;"
"end."


[event_3]
s="// Telescope move event"
"var"
"    ra,de: double;"
"begin"
" getD('TelescopeRA',ra);"
" getD('TelescopeDE',de);"
" ra:=ra*rad2deg/15;"
" de:=de*rad2deg;"
" Edit_3.text:=ARtoStr(ra);"
" Edit_4.text:=DEtoStr(de);"
"end."


[event_4]
s="// Chart refresh event"
"var str,buf: string;"
"    p: integer;"
"begin"
"  // ensure the target coordinate field is not empty"
"  if (Edit_1.text='')and(Edit_2.text='') then begin"
"   // coordinates from chart center"
"   getS('RefreshText',str)"
"   p:=pos('C:',str);"
"   if p>0 then begin"
"     delete(str,1,p+1);"
"     str:=trim(str);"
"     // RA"
"     p:=pos(' ',str);"
"     buf:=trim(copy(str,1,p));"
"     edit_1.text:=buf;"
"     delete(str,1,p);"
"     // Dec"
"     p:=pos(' ',str);"
"     buf:=trim(copy(str,1,p));"
"     edit_2.text:=buf;"
"   end;"
" end;"
"end."


[event_5]
s="// Object identification event"
"var str,buf,longstr: string;"
"    p: integer;"
"begin"
"// Info about object"
" getS('SelectionText',str)"
" getS('DescriptionText',longstr)"
"// Get RA"
" p:=pos(chr(9),str);"
" buf:=copy(str,1,p-1);"
" edit_1.text:=buf;"
" delete(str,1,p);"
"// Get Dec"
" p:=pos(chr(9),str);"
" buf:=copy(str,1,p-1);"
" edit_2.text:=buf;"
" delete(str,1,p);"
"// show other information line by line"
" memo_1.clear;"
" memo_1.text:=longstr;"
" memo_1.selstart:=0;"
"end."


[event_6]
s="// Distance event"
"var str: string;"
"begin"
" getS('DistanceText',str)"
" memo_1.clear;"
" memo_1.lines.add(rsDistance+' '+str);"
"end."


[event_7]
s="// Telescope connected"
"var cm: Tstringlist;"
"    ra,de: double;"
"begin"
"  // moving rates"
"  Combo_1.clear;"
"  GetSL('STRL1',cm);"
"  cm.clear;"
"  GetScopeRates(cm);"
"  Combo_1.items.assign(cm);"
"  Combo_1.itemindex:=0;"
"// Telescope position"
"  getD('TelescopeRA',ra);"
"  getD('TelescopeDE',de);"
"  ra:=ra*rad2deg/15;"
"  de:=de*rad2deg;"
"  Edit_3.text:=ARtoStr(ra);"
"  Edit_4.text:=DEtoStr(de);"
"  cm.clear;"
"end."


[event_8]
s="// Telescope disconnect"
"begin"
" Combo_1.clear;"
" Edit_3.text:='';"
" Edit_4.text:='';"
"end."


[event_9]
s="// translation"
"begin"
"  CheckList_1.Items[0]:=rsSwapButton+' N/S';"
"  CheckList_1.Items[1]:=rsSwapButton+' E/W';"
"  group_7.caption:=rsTarget;"
"  group_1.caption:=rsTelescope;"
"  button_1.caption:=rsSlew;"
"  button_2.caption:=rsSync;"
"  button_3.caption:=rsAbortSlew;"
"  button_4.caption:=rsTrackTelesco;"
"  button_5.caption:=rsConnect;"
"  group_4.caption:=rsHandpad;"
"  button_11.caption:=rsStop;"
"  button_14.caption:=rsSearch;"
"  group_3.caption:=rsObservingLis;"
"  button_7.caption:=rsFirst;"
"  button_8.caption:=rsLast;"
"  button_5.caption:='< '+rsPrevious;"
"  button_6.caption:=rsNext2+' >';"
"  group_2.caption:=rsInfo;"
"end."

